package com.qingzhuge.manager.dao;


import com.qingzhuge.dao.BasePkLongDao;
import com.qingzhuge.manager.entity.SysUser;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * @author : zero.xiao
 * @description : 系统用户
 * @date :2018/6/8 0008 下午 14:54
 * @modified :
 */
public interface SysUserDao extends BasePkLongDao<SysUser> {

    SysUser findByUsernameOrMobile(String account,String mobile);

    @Query("select new SysUser(u.id,u.name) from SysUser u where u.root = true")
    SysUser findByRoot();

    @Query("select new SysUser(u.id,u.name) from SysUser u where u.root = ?1")
    List<SysUser> findListByRoot(boolean root);

    int countByRootFalse();

    @Modifying
    @Query("update SysUser u set u.password = :password where u.id = :id")
    void updatePassword(@Param("id") Long id,@Param("password") String password);

    List<SysUser> findListByDeptId(Long id);
}
